#ifndef __LIB_AGORA_ADMIN_IDATABASE_H__
#define __LIB_AGORA_ADMIN_IDATABASE_H__

#include <string>
#include <vector>
#include <map>
#include "IDbValue.h"

class	IDatabase
{
public:
	typedef std::vector<std::map<std::string, IDbValue*>*>	DbResult;
	virtual const unsigned int	Open(const std::string& dbPath) = 0; //facon SQLite voir pour generaliser a toutes db
	virtual const unsigned int	Close() = 0;
	
	// TODO fonction gestion db avec les ID (channel, user, droit)
	// UserManager db functions
	virtual DbResult*			SelectAllUser() = 0;
	virtual DbResult*			SelectUser(const unsigned int id) = 0;
	virtual DbResult*			SelectUser(const std::string& login) = 0;
	virtual void				UpdateUser(const unsigned int id, const std::string& login, const std::string& password) = 0;
	virtual const unsigned int	CreateUser(const std::string& login, const std::string& password) = 0;
	virtual void				DeleteAllUser() = 0;
	virtual void				DeleteUser(const unsigned int id) = 0;
	//// User db funtions
	virtual const unsigned int	SelectUserId(const std::string& login) = 0;
	virtual std::string			SelectUserLogin(const unsigned int id) = 0;
	virtual void				UpdateUserLogin(const unsigned int id, const std::string& login) = 0;
	virtual std::string			SelectUserPassword(const unsigned int id) = 0;
	virtual void				UpdateUserPassword(const unsigned int id, const std::string& password) = 0;
	//// ChannelManager db functions
	virtual DbResult*			SelectAllChannel() = 0;
	virtual DbResult*			SelectChannel(const unsigned int idParent, const std::string& name) = 0;
	//virtual void				UpdateAllChannel() = 0;
	//virtual void				UpdateChannel(const unsigned int id) = 0;
	virtual const unsigned int	CreateChannel(const unsigned int idParent, const std::string& name, const unsigned int maxNameLenght, const std::string& password, const unsigned int maxPasswordLenght, const std::string& motd, const unsigned int maxMotdLenght, const std::string& description, const unsigned int maxDescriptionLenght, const bool visible, const unsigned int maxUser, const unsigned int maxTalker) = 0;
	virtual void				DeleteAllChannel() = 0;
	virtual void				DeleteChannel(const unsigned int id) = 0;
	//// Channel db functions
	virtual const unsigned int	SelectChannelId(const unsigned int idParent, const std::string& name) = 0;
	virtual const unsigned int	SelectChannelIdParent(const unsigned int id) = 0;
	virtual void				UpdateChannelIdParent(const unsigned int id, const unsigned int idParent) = 0;
	virtual const std::string&	SelectChannelName(const unsigned int id) = 0;
	virtual void				UpdateChannelName(const unsigned int id, const std::string& name) = 0;
	virtual const unsigned int	SelectChannelMaxNameLenght(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxNameLenght(const unsigned int id, const unsigned int maxNameLenght) = 0;
	virtual const std::string&	SelectChannelPassword(const unsigned int id) = 0;
	virtual void				UpdateChannelPassword(const unsigned int id, const std::string& password) = 0;
	virtual const unsigned int	SelectChannelMaxPasswordLenght(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxPasswordLenght(const unsigned int id, const unsigned int maxPasswordLenght) = 0;
	virtual const std::string&	SelectChannelMotd(const unsigned int id) = 0;
	virtual void				UpdateChannelMotd(const unsigned int id, const std::string& motd) = 0;
	virtual const unsigned int	SelectChannelMaxMotdLenght(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxMotdLenght(const unsigned int id, const unsigned int maxMotdLenght) = 0;
	virtual const std::string&	SelectChannelDescription(const unsigned int id) = 0;
	virtual void				UpdateChannelDescription(const unsigned int id, const std::string& description) = 0;
	virtual const unsigned int	SelectChannelMaxDesciptionLenght(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxDesciptionLenght(const unsigned int id, const unsigned int maxDescriptionLenght) = 0;
	virtual const bool			SelectChannelVisibility(const unsigned int id) = 0;
	virtual void				UpdateChannelVisibility(const unsigned int id, const bool visible) = 0;
	virtual const unsigned int	SelectChannelMaxUser(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxUser(const unsigned int id, const unsigned int maxUser) = 0;
	virtual const unsigned int	SelectChannelMaxTalker(const unsigned int id) = 0;
	virtual void				UpdateChannelMaxTalker(const unsigned int id, const unsigned int maxTalker) = 0;
	//// Right db functions
	virtual DbResult*			SelectChannelRight(const unsigned int id) = 0;
	virtual DbResult*			SelectChannelRight(const unsigned int idUser, const unsigned int idChannel) = 0;
	virtual const unsigned int	SelectChannelRightId(const unsigned int idUser, const unsigned int idChannel) = 0;
	virtual const unsigned int	CreateChannelRightDefault(const unsigned int idUser, const unsigned int idChannel) = 0;
	virtual void				UpdateChannelRight(const unsigned int id, const bool canCreate, const bool canDelete, const bool canEdit, const bool canEditUser, const bool canTalk, const bool canWrite, const bool canKick, const bool canBan) = 0;
	virtual void				UpdateChannelRightCanCreateChild(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanDeleteChild(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanEdit(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanEditUserRight(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanTalk(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanWrite(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanKick(const unsigned int id, const bool value) = 0;
	virtual void				UpdateChannelRightCanBan(const unsigned int id, const bool value) = 0;
	//// Server db functions
	virtual const std::string&	SelectServerName() = 0;
	virtual void				UpdateServerName(const std::string& name) = 0;
	virtual DbResult*			SelectServerBanListLogin() = 0;
	virtual void				InsertServerBanListLogin(const std::string& login) = 0;
	virtual void				DeleteServerBanListLogin(const std::string& login) = 0;
private:
	virtual const unsigned int	Execute(const std::string& statement, DbResult* result) = 0;
	virtual const unsigned int	Execute(const std::string& statement) = 0;
};

#endif